Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a namespace-based architecture for enum field registration, decoupling it from ActiveRecord models. The changes enable standalone enum field definitions that can be registered in initializers or shared configuration without requiring a backing model.
Changes:
- Refactored
EnumFields.registerto acceptnamespaceinstead ofmodel_classparameter - Added
EnumFields.namespaceDSL for standalone enum field registration outside models - Added
EnumFields.catalogmethod to provide alphabetically-sorted, serialization-friendly view of all registered definitions
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/enum_fields.rb | Added namespace and catalog class methods to support new DSL and data export |
| lib/enum_fields/registry.rb | Refactored register to accept namespace parameter and added catalog method for sorted output |
| lib/enum_fields/namespace.rb | New class providing DSL context for standalone enum field registration |
| lib/enum_fields/enum_field.rb | Updated to derive namespace from model class name when registering |
| spec/enum_fields/registry.spec.rb | Comprehensive test updates covering new namespace DSL, catalog functionality, and edge cases |
| README.md | Added documentation for standalone registration via namespace DSL and catalog method |
| .rubocop.yml | Updated target Ruby version from 2.7 to 3.4 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR serves to decouple enum field registration from ActiveRecord models by introducing a
namespaceconcept to the registry. Definitions can now be registered standalone viaEnumFields.namespace(:name) { enum_field ... }, making the gem useful for centralizing enum definitions in initializers or shared configuration without requiring a backing model.In addition, a new
EnumFields.catalogmethod provides a sorted, serialization-friendly view of all registered definitions across both model-derived and standalone namespaces.